/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uloha4.entities;

/**
 *
 * @author Tomique
 */
public class Component<T extends Node> extends MyList<Node> {

    private int nodes;              // pocet uzlu v komponente
    private int edges;              // pocet hran v komponente
    private String representative;  // jmeno uzlu, ze ktereho vede nejvice hran
    private int edgesMax;
    private boolean visible;        // flag, zda je dana komponenta vizualizovana
    
    public Component() {
        nodes = 0;
        edges = 0;
        representative = "unset";
        edgesMax = Integer.MIN_VALUE;
        visible = true;
    }

    public int getEdges() {
        return edges;
    }

    public boolean isVisible() {
        return visible;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    public int getNodes() {
        return nodes;
    }

    public String getRepresentative() {
        return representative;
    }

    @Override
    public void add(Node node) {
        super.add(node);        
        ++nodes;
        int neighbours = node.getNoOfNeighbours();
        edges += neighbours;
        if(neighbours > edgesMax) {
            edgesMax = neighbours;
            representative = node.getAuthorName();
        }
    }
}
